#pragma once

#include <AVUIDependencyObject.h>

namespace AVUI {

class FilterEventArgs;
class CollectionView;

class CollectionViewSource : public DependencyObject
{
    friend class ItemCollection;
    friend class PropertyPathWorker;
public:

    DECLARE_ELEMENT(CollectionViewSource, DependencyObject);

    DECLARE_READONLY_DEPENDENCY_PROPERTY(View);
    TRefCountedPtr<CollectionView> get_View() { return (CollectionView*)(Object*)GetValue(get_ViewProperty()); }

    DECLARE_DEPENDENCY_PROPERTY(Source);
    TRefCountedPtr<Object> get_Source() { return GetValue(get_SourceProperty()); }
    void set_Source(Object* pValue) { SetValue(get_SourceProperty(), pValue); } 

    DECLARE_DEPENDENCY_PROPERTY(CollectionViewType);
    const Type* get_CollectionViewType() { return (const Type*)(Object*)GetValue(get_CollectionViewTypeProperty()); }
    void set_CollectionViewType(const Type* pType) { SetValue(get_CollectionViewTypeProperty(), (Object*)pType); } 

    IMPLEMENT_EVENT(Filter, FilterEventArgs);

    CollectionView* get_CollectionView();

    DependencyProperty* get_PropertyForInheritanceContext() { return NULL; }

private:
    static void StaticConstructor();
    static TRefCountedPtr<CollectionView> GetDefaultCollectionView(Object* pSource);
    static TRefCountedPtr<CollectionView> GetDefaultCollectionView(Object* pSource, DependencyObject* pDO);

 


    static void OnSourceChanged(Object* pDO, DependencyPropertyChangedEventArgs* e);
    static void OnCollectionViewTypeChanged(Object* pDO, DependencyPropertyChangedEventArgs* e);

};

}; // namespace AVUI
